#include <stdio.h>

const int MEGA_NUMBER = 10000;
const int MAX_CNT = 50000;
int a1[MAX_CNT];
int a2[MAX_CNT];
int N1 = 0;
int N2 = 0;

bool binary_search(int num) {
    int l = 0;
    int r = N2-1;

    if (num > a2[l] || a2[r] > num)
        return false;

    while(l <= r) {
        int m = (l + r) >> 1;
        const int tmp = a2[m];
        if (tmp == num)
            return true;
        else if (num > tmp)
            r = m - 1;
        else
            l = m + 1;
    }
}

int main() {
    /*N2 = 4;
    a2[0] = 10;
    a2[1] = 5;
    a2[2] = 1;
    a2[3] = -100;
    bool found = binary_search(0);
    printf(found ? "true\n" : "false\n");
    return 0;*/

    scanf("%d", &N1);
    for (int i = 0; i < N1; ++i) {
        int tmp;
        scanf("%d", &tmp);
        a1[i] = tmp;
    }

    scanf("%d", &N2);
    for (int i = 0; i < N2; ++i) {
        int tmp;
        scanf("%d", &tmp);
        a2[i] = tmp;
    }

    //
    bool res = false;
    for (int i = 0; i < N1; ++i)
        if (binary_search(MEGA_NUMBER - a1[i])) {
            res = true;
            break;
        }

    printf(res ? "YES\n" : "NO\n");

    return 0;
}
